import { Dingtalk } from "../dingtalk";
import DingTalkBasePublicService from "./BasePublicService";

/**
 * 钉钉待办相关接口
 */
export default class PlatformDingtalkBaseTodoService extends DingTalkBasePublicService {
	/**
	 * 创建待办
	 *
	 * @param {string} creatorId 创建者
	 * @param {string} operatorId 操作者
	 * @param {dingTalk.nv.request.ICreateTodo} params 待办参数
	 * @return {*}
	 * @memberof PlatformDingtalkBaseTodoService
	 */
	async createTodo(creatorId: string, operatorId: string, params: Dingtalk.nv.request.ICreateTodo) {
		const url = `/v1.0/todo/users/${creatorId}/tasks?operatorId=${operatorId}`;
		const res = await this.nvRequest<Dingtalk.nv.response.ICreateTodoResponse>(url, {
			method: "POST",
			data: {
				...params,
			},
		});
		return res;
	}
}
